package com.dindang.propertyfee.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.dindang.propertyfee.R;
import com.dindang.propertyfee.di.component.DaggerFeeAdvancedSearchComponent;
import com.dindang.propertyfee.di.module.FeeAdvancedSearchModule;
import com.dindang.propertyfee.mvp.contract.FeeAdvancedSearchContract;
import com.dindang.propertyfee.mvp.presenter.FeeAdvancedSearchPresenter;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;


import static com.jess.arms.utils.Preconditions.checkNotNull;

@Route(path = "/propertyfee/activity/FeeAdvancedSearchActivity")
public class FeeAdvancedSearchActivity extends BaseActivity<FeeAdvancedSearchPresenter> implements FeeAdvancedSearchContract.View {

    ImageView mIvBack;
    TextView mTvTitle;
    TextView mTvDataStart;
    TextView mTvDataEnd;
    TextView mTvVillageName;
    TextView mTvBuild;
    TextView mTvUnit;
    TextView mTvFloor;
    TextView mTvRoomNumber;
    TextView mTvCommit;
    RecyclerView mListview;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerFeeAdvancedSearchComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .feeAdvancedSearchModule(new FeeAdvancedSearchModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.propertyfee_activity_fee_advanced_search; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mIvBack = findViewById(R.id.propertyfee_iv_back);
        mTvTitle = findViewById(R.id.propertyfee_tv_title);
        mTvDataStart = findViewById(R.id.propertyfee_tv_data_start);
        mTvDataEnd = findViewById(R.id.propertyfee_tv_data_end);
        mTvVillageName = findViewById(R.id.propertyfee_tv_village_name);
        mTvBuild = findViewById(R.id.propertyfee_tv_build);
        mTvUnit = findViewById(R.id.propertyfee_tv_unit);
        mTvFloor = findViewById(R.id.propertyfee_tv_floor);
        mTvRoomNumber = findViewById(R.id.propertyfee_tv_room_number);
        mTvCommit = findViewById(R.id.propertyfee_tv_commit);

        mListview = findViewById(R.id.propertyfee_listview);

        mTvTitle.setText("条件查找");
        mIvBack.setOnClickListener(v -> mPresenter.finish());
        mPresenter.init();
        mTvCommit.setOnClickListener(v -> mPresenter.toSearch());
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public TextView getTvDataStart() {
        return mTvDataStart;
    }

    @Override
    public TextView getTvDataEnd() {
        return mTvDataEnd;
    }

    @Override
    public TextView getTvVillageName() {
        return mTvVillageName;
    }

    @Override
    public TextView getTvBuild() {
        return mTvBuild;
    }

    @Override
    public TextView getTvUnit() {
        return mTvUnit;
    }

    @Override
    public TextView getTvFloor() {
        return mTvFloor;
    }

    @Override
    public TextView getTvRoomNumber() {
        return mTvRoomNumber;
    }

    @Override
    public TextView getTvCommit() {
        return mTvCommit;
    }

    @Override
    public RecyclerView getListview() {
        return mListview;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }

    @Override
    public void onBackPressed() {
        // super.onBackPressed();
        mPresenter.finish();
    }
}
